package com.ceair.flight.refund.location.model;

import com.ceair.flight.refund.util.DateUtil;
import com.ceair.flight.refund.util.StringUtil;
import com.ceair.muservice.common.dto.AbstractBaseDO;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;


public class SegmentDO extends AbstractBaseDO implements Serializable, Comparable<com.ceair.flight.refund.location.model.SegmentDO> {

    /**
     *
     */
    private static final long serialVersionUID = -1354450011418149493L;
    /**
     * 航段id *
     */
    private Long segId;
    /**
     * 第几航段 *
     */
    private Integer segSq;
    /**
     * 第几航程 *
     */
    private Integer tripSq;
    /**
     * 改升前航段id *
     */
    private Long oldSegId;
    /**
     * 航段状态 "REFUNDED","退票""VOID","作废""SUSPENDED","挂起""CHANGED","换开""OPEN_FOR_USE","待使用"*
     */
    private String segSt;
    /**
     * 市场方航班号 *
     */
    private String flightNo;
    /**
     * 市场方航空公司 *
     */
    private String carrCd;
    /**
     * 承运人航班 号 *
     */
    private String realFlightNo;
    /**
     * 承运人航空公司 *
     */
    private String realCarrCd;
    /**
     * 出发日期 *
     */
    private Date depDt;
    /**
     * 出发时间 *
     */
    private String depTm;
    /**
     * 到达日期 *
     */
    private Date arrDt;
    /**
     * 到达时间 *
     */
    private String arrTm;
    /**
     * 到达机场三字码 *
     */
    private String arrAirpCd;
    /**
     * 出发机场三字码 *
     */
    private String depAirpCd;
    /**
     * 舱位 *
     */
    private String classTp;
    /**
     * 大客户折扣率 *
     */
    private Integer discountGm;
    /**
     * 父舱全价 *
     */
    private Integer baseClassAm;
    /**
     * 航段票面价 *
     */
    private BigDecimal fcny;
    /**
     * 航段销售价 *
     */
    private BigDecimal scny;
    /**
     * 航段税费 *
     */
    private BigDecimal taxAm;
    /**
     * 航段代理费 *
     */
    private BigDecimal agentAm;
    /**
     * 票面价差价 *
     */
    private BigDecimal fcnyDiff;
    /**
     * 销售价差价 *
     */
    private BigDecimal scnyDiff;
    /**
     * 代理费 *
     */
    private BigDecimal agentCam;
    /**
     * 直减费 *
     */
    private BigDecimal agentZam;
    /**
     * 代理费差价 *
     */
    private BigDecimal agentCamDiff;
    /**
     * 直减费差价 *
     */
    private BigDecimal agentZamDiff;
    /**
     * 代理费率 *
     */
    private BigDecimal discountC;
    /**
     * 直减费率 *
     */
    private BigDecimal discountZ;
    /**
     * fb项 *
     */
    private String fb;
    /**
     * 旅行代码 *
     */
    private String tourCode;
    /**
     * 优惠政策id *
     */
    private Long ruleId;
    /**
     * ei *
     */
    private String ei;
    /**
     * 退改签描述 *
     */
    private String ecomment;
    /**
     * 行李重量（含单位） *
     */
    private String baggageWeight;
    /**
     * 客票最短停留期 *
     */
    private String minStay;
    /**
     * 客票最长停留期 *
     */
    private String maxStay;
    /**
     * pnr号 *
     */
    private String pnrCd;
    /**
     * 飞机订单号 *
     */
    private String flightOrderNo;
    /**
     * 乘客序号 *
     */
    private Long passengerId;
    /**
     * 到达航站楼*
     */
    private String arrTerm;
    /**
     * 出发航站楼*
     */
    private String depTerm;
    /**
     * 仓等*
     */
    private String cabinClass;
    /**
     * 机型*
     */
    private String equipment;
    /**
     * 是否有WIFI*
     */
    private boolean iswifi;
    /**
     * 是否为共享航班*
     */
    private boolean iscodeshare;
    /**
     * 是否有餐时*
     */
    private boolean ismeal;
    /**
     * 是否国际航班*
     */
    private boolean isinter;
    /**
     * 币种*
     */
    private String currency;
    /**
     * 票号id*
     */
    private Long tktID;

    /**
     * 税项 *
     */
    private Set<TaxFeeDO> taxFees;
    /**
     * 退改签规则 *
     */
    private Set<SegrpuDO> segrpu;

    /**
     * 是否经停*
     */
    private boolean stop = false;// 是否经停
    /**
     * 经停点 *
     */
    private String stops;// 经停点
    /**
     * 经停时长 *
     */
    private String stopTime;
    /**
     * 飞行时间*
     */
    private String duration;
    /**
     * 促销产品码
     * @return
     */
    private String productCode;
    /**
     * 优惠金额
     * @return
     */
    private BigDecimal promoAmount;

    /**
     * 积分总额 *
     */
    private BigDecimal pointAmount;


	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

    public Long getSegId() {
        return segId;
    }

    public void setSegId(Long segId) {
        this.segId = segId;
    }

    public Integer getSegSq() {
        return segSq;
    }

    public Integer getTripSq() {
        return tripSq;
    }

    public void setTripSq(Integer tripSq) {
        this.tripSq = tripSq;
    }

    public void setSegSq(Integer segSq) {
        this.segSq = segSq;
    }

    public Long getOldSegId() {
        return oldSegId;
    }

    public void setOldSegId(Long oldSegId) {
        this.oldSegId = oldSegId;
    }

    public String getSegSt() {
        return segSt;
    }

    public void setSegSt(String segSt) {
        this.segSt = segSt;
    }

    public String getFlightNo() {
        return flightNo;
    }

    public void setFlightNo(String flightNo) {
        this.flightNo = flightNo;
    }

    public String getRealFlightNo() {
        return realFlightNo;
    }

    public void setRealFlightNo(String realFlightNo) {
        this.realFlightNo = realFlightNo;
    }

    public String getRealCarrCd() {
        return realCarrCd;
    }

    public void setRealCarrCd(String realCarrCd) {
        this.realCarrCd = realCarrCd;
    }

    public String getCarrCd() {
        return carrCd;
    }

    public void setCarrCd(String carrCd) {
        this.carrCd = carrCd;
    }

    public Date getDepDt() {
        return depDt;
    }

    public void setDepDt(Date depDt) {
        this.depDt = depDt;
    }

    public String getDepTm() {
        return depTm;
    }

    public void setDepTm(String depTm) {
        this.depTm = depTm;
    }

    public Date getArrDt() {
        return arrDt;
    }

    public void setArrDt(Date arrDt) {
        this.arrDt = arrDt;
    }

    public String getArrTm() {
        return arrTm;
    }

    public void setArrTm(String arrTm) {
        this.arrTm = arrTm;
    }

    public String getArrAirpCd() {
        return arrAirpCd;
    }

    public void setArrAirpCd(String arrAirpCd) {
        this.arrAirpCd = arrAirpCd;
    }

    public String getDepAirpCd() {
        return depAirpCd;
    }

    public void setDepAirpCd(String depAirpCd) {
        this.depAirpCd = depAirpCd;
    }

    public String getClassTp() {
        return classTp;
    }

    public void setClassTp(String classTp) {
        this.classTp = classTp;
    }

    public Integer getDiscountGm() {
        return discountGm;
    }

    public void setDiscountGm(Integer discountGm) {
        this.discountGm = discountGm;
    }

    public Integer getBaseClassAm() {
        return baseClassAm;
    }

    public void setBaseClassAm(Integer baseClassAm) {
        this.baseClassAm = baseClassAm;
    }

    public BigDecimal getFcny() {
        return fcny;
    }

    public void setFcny(BigDecimal fcny) {
        this.fcny = fcny;
    }

    public BigDecimal getScny() {
        return scny;
    }

    public void setScny(BigDecimal scny) {
        this.scny = scny;
    }

    public BigDecimal getTaxAm() {
        return taxAm;
    }

    public void setTaxAm(BigDecimal taxAm) {
        this.taxAm = taxAm;
    }

    public BigDecimal getAgentAm() {
        return agentAm;
    }

    public void setAgentAm(BigDecimal agentAm) {
        this.agentAm = agentAm;
    }

    public BigDecimal getFcnyDiff() {
        return fcnyDiff;
    }

    public void setFcnyDiff(BigDecimal fcnyDiff) {
        this.fcnyDiff = fcnyDiff;
    }

    public BigDecimal getScnyDiff() {
        return scnyDiff;
    }

    public void setScnyDiff(BigDecimal scnyDiff) {
        this.scnyDiff = scnyDiff;
    }

    public BigDecimal getAgentCam() {
        return agentCam;
    }

    public void setAgentCam(BigDecimal agentCam) {
        this.agentCam = agentCam;
    }

    public BigDecimal getAgentZam() {
        return agentZam;
    }

    public void setAgentZam(BigDecimal agentZam) {
        this.agentZam = agentZam;
    }

    public BigDecimal getAgentCamDiff() {
        return agentCamDiff;
    }

    public void setAgentCamDiff(BigDecimal agentCamDiff) {
        this.agentCamDiff = agentCamDiff;
    }

    public BigDecimal getAgentZamDiff() {
        return agentZamDiff;
    }

    public void setAgentZamDiff(BigDecimal agentZamDiff) {
        this.agentZamDiff = agentZamDiff;
    }

    public BigDecimal getDiscountC() {
        return discountC;
    }

    public void setDiscountC(BigDecimal discountC) {
        this.discountC = discountC;
    }

    public BigDecimal getDiscountZ() {
        return discountZ;
    }

    public void setDiscountZ(BigDecimal discountZ) {
        this.discountZ = discountZ;
    }

    public String getFb() {
        return fb;
    }

    public void setFb(String fb) {
        this.fb = fb;
    }

    public String getTourCode() {
        return tourCode;
    }

    public void setTourCode(String tourCode) {
        this.tourCode = tourCode;
    }

    public Long getRuleId() {
        return ruleId;
    }

    public void setRuleId(Long ruleId) {
        this.ruleId = ruleId;
    }

    public String getEi() {
        return ei;
    }

    public void setEi(String ei) {
        this.ei = ei;
    }

    public String getEcomment() {
        return ecomment;
    }

    public void setEcomment(String ecomment) {
        this.ecomment = ecomment;
    }

    public String getBaggageWeight() {
        return baggageWeight;
    }

    public void setBaggageWeight(String baggageWeight) {
        this.baggageWeight = baggageWeight;
    }

    public String getMinStay() {
        return minStay;
    }

    public void setMinStay(String minStay) {
        this.minStay = minStay;
    }

    public String getMaxStay() {
        return maxStay;
    }

    public void setMaxStay(String maxStay) {
        this.maxStay = maxStay;
    }

    public String getPnrCd() {
        return pnrCd;
    }

    public void setPnrCd(String pnrCd) {
        this.pnrCd = pnrCd;
    }

    public String getFlightOrderNo() {
        return flightOrderNo;
    }

    public void setFlightOrderNo(String flightOrderNo) {
        this.flightOrderNo = flightOrderNo;
    }

    public Long getPassengerId() {
        return passengerId;
    }

    public void setPassengerId(Long passengerId) {
        this.passengerId = passengerId;
    }

    public Set<TaxFeeDO> getTaxFees() {
        return taxFees;
    }

    public void setTaxFees(Set<TaxFeeDO> taxFees) {
        this.taxFees = taxFees;
    }

    public void addTaxFees(TaxFeeDO taxFee) {
        if (this.taxFees == null) {
            this.taxFees = new HashSet<>();
        }
        this.taxFees.add(taxFee);
    }

    public Set<SegrpuDO> getSegrpu() {
        return segrpu;
    }

    public Set<SegrpuDO> getNonEmptySegrpu() {
        return this.segrpu == null ? Collections.EMPTY_SET : this.segrpu;
    }

    public void setSegrpu(Set<SegrpuDO> segrpu) {
        this.segrpu = segrpu;
    }

    public void addSegrpu(SegrpuDO rpu) {
        if (this.segrpu == null) {
            this.segrpu = new HashSet<>();
        }
        this.segrpu.add(rpu);
    }

    public String getArrTerm() {
        return arrTerm;
    }

    public void setArrTerm(String arrTerm) {
        this.arrTerm = arrTerm;
    }

    public String getDepTerm() {
        return depTerm;
    }

    public void setDepTerm(String depTerm) {
        this.depTerm = depTerm;
    }

    public String getCabinClass() {
        return cabinClass;
    }

    public void setCabinClass(String cabinClass) {
        this.cabinClass = cabinClass;
    }

    public String getEquipment() {
        return equipment;
    }

    public void setEquipment(String equipment) {
        this.equipment = equipment;
    }

    public boolean getIswifi() {
        return iswifi;
    }

    public void setIswifi(boolean iswifi) {
        this.iswifi = iswifi;
    }

    public boolean getIscodeshare() {
        return iscodeshare;
    }

    public void setIscodeshare(boolean iscodeshare) {
        this.iscodeshare = iscodeshare;
    }

    public boolean getIsmeal() {
        return ismeal;
    }

    public void setIsmeal(boolean ismeal) {
        this.ismeal = ismeal;
    }

    public boolean getIsinter() {
        return isinter;
    }

    public void setIsinter(boolean isinter) {
        this.isinter = isinter;
    }

    public Long getTktID() {
        return tktID;
    }

    public void setTktID(Long tktID) {
        this.tktID = tktID;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    
    public BigDecimal getPromoAmount() {
		return promoAmount;
	}

	public void setPromoAmount(BigDecimal promoAmount) {
		this.promoAmount = promoAmount;
	}

    public BigDecimal getPointAmount() {
        return pointAmount;
    }

    public void setPointAmount(BigDecimal pointAmount) {
        this.pointAmount = pointAmount;
    }

    public boolean isStop() {
        return stop;
    }

    public void setStop(boolean stop) {
        this.stop = stop;
    }

    public String getStops() {
        return stops;
    }

    public void setStops(String stops) {
        this.stops = stops;
    }

    public String getStopTime() {
        return stopTime;
    }

    public void setStopTime(String stopTime) {
        this.stopTime = stopTime;
    }
    /**
     * 积分种类*
     */
    private String pointTp;

    public String getPointTp() {
        return pointTp;
    }

    public void setPointTp(String pointTp) {
        this.pointTp = pointTp;
    }

    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }
    
    public Date getArrDateAndTime() {
    	if (this.arrDt != null && this.arrTm != null) {
    		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    		String date = dateFormat.format(this.arrDt);
    		String dateTime = date + " " + this.arrTm;
    		dateFormat.applyPattern("yyyy-MM-dd HH:mm");
    		try {
    			Date depDate = dateFormat.parse(dateTime);
    			return depDate;
    		} catch (ParseException ex) {
    			//ignore
    		}
    	}
    	return null;
    }

    public Date getDepDateAndTime() {
        if (this.depDt != null && this.depTm != null) {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            String date = dateFormat.format(this.depDt);
            String dateTime = date + " " + this.depTm;
            dateFormat.applyPattern("yyyy-MM-dd HH:mm");
            try {
                Date depDate = dateFormat.parse(dateTime);
                return depDate;
            } catch (ParseException ex) {
                //ignore
            }
        }
        return null;
    }

    @Override
    public int compareTo(com.ceair.flight.refund.location.model.SegmentDO dest) {
        return this.segSq - dest.segSq;
    }

	@Override
	public String toString() {
		return  segId + StringUtil.SEPARATOR + segSq+ StringUtil.SEPARATOR + oldSegId + StringUtil.SEPARATOR + flightOrderNo + StringUtil.SEPARATOR + passengerId
				+ StringUtil.SEPARATOR + tktID+ StringUtil.SEPARATOR + segSt+ StringUtil.SEPARATOR + flightNo
				+ StringUtil.SEPARATOR+ realFlightNo+ StringUtil.SEPARATOR + realCarrCd
				 + StringUtil.SEPARATOR + DateUtil.toString(depDt, StringUtil.DATEFORMATE) + StringUtil.SEPARATOR + depTm + StringUtil.SEPARATOR
				+ DateUtil.toString(arrDt, StringUtil.DATEFORMATE) + StringUtil.SEPARATOR + arrTm + StringUtil.SEPARATOR + arrAirpCd + StringUtil.SEPARATOR + depAirpCd + StringUtil.SEPARATOR
				+ classTp + StringUtil.SEPARATOR + discountGm + StringUtil.SEPARATOR + baseClassAm + StringUtil.SEPARATOR + fcny + StringUtil.SEPARATOR
				+ scny + StringUtil.SEPARATOR + taxAm + StringUtil.SEPARATOR + agentAm + StringUtil.SEPARATOR + fcnyDiff + StringUtil.SEPARATOR
				+ scnyDiff + StringUtil.SEPARATOR + agentCam + StringUtil.SEPARATOR + agentZam + StringUtil.SEPARATOR + agentCamDiff
				+ StringUtil.SEPARATOR + agentZamDiff + StringUtil.SEPARATOR + discountC + StringUtil.SEPARATOR + discountZ + StringUtil.SEPARATOR
				+ fb + StringUtil.SEPARATOR + tourCode + StringUtil.SEPARATOR + ruleId+ StringUtil.SEPARATOR + StringUtil.replaceBlank(ecomment)
				+ StringUtil.SEPARATOR + baggageWeight + StringUtil.SEPARATOR + minStay + StringUtil.SEPARATOR + maxStay + StringUtil.SEPARATOR
				+ pnrCd + StringUtil.SEPARATOR+createId+ StringUtil.SEPARATOR+deleted+ StringUtil.SEPARATOR + DateUtil.toString(createDtm, StringUtil.DATEFORMATE)
				+ StringUtil.SEPARATOR+updateId+ StringUtil.SEPARATOR + DateUtil.toString(updateDtm, StringUtil.DATEFORMATE)+ StringUtil.SEPARATOR+version+ StringUtil.SEPARATOR + StringUtil.replaceBlank(ei)
				+ StringUtil.SEPARATOR + tripSq
				 + StringUtil.SEPARATOR + carrCd+ StringUtil.SEPARATOR+ arrTerm
				+ StringUtil.SEPARATOR + depTerm + StringUtil.SEPARATOR + cabinClass + StringUtil.SEPARATOR + equipment + StringUtil.SEPARATOR
				+ iswifi + StringUtil.SEPARATOR + iscodeshare + StringUtil.SEPARATOR + ismeal + StringUtil.SEPARATOR + isinter
				+ StringUtil.SEPARATOR + currency+ StringUtil.SEPARATOR + pointAmount+ StringUtil.SEPARATOR + stop + StringUtil.SEPARATOR + stopTime
				+ StringUtil.SEPARATOR + stops+ StringUtil.SEPARATOR + pointTp + StringUtil.SEPARATOR + duration+ StringUtil.SEPARATOR + productCode
				+ StringUtil.SEPARATOR + promoAmount;
	}

    
}
